Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Server or client-side clock/date display

  1. #21
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,566

    Default

    my script uses the one included in reborn_pak8.pk3 :P


    would it even give an error ?

  2. #22
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    On a linux server it might, linux server is more temperamental when it comes to lowercase vs uppercase. But chances are with this problem, he just doesnt have any version of strings.scr in there.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  3. #23
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,566

    Default

    he should , getdate & gettime are working == reborn is installed == pak8 exists == there is strings.scr

    bright rygorithm

  4. #24

    Default

    Hi lads, thanks again.

    Interesting - that script still didn't work for me. So I did a bit of probing - it kept failing on:

    "local.time = waitexec global/strings.scr::left local.time.size-3 local.time" for me.

    So i decided to define local.number first, and that seems to have done the trick!? Weird!? (see below).

    For anyone interested - this calls date and time with ticking seconds removed! Great success.

    Thank you for your help, lads. This process has taught me a little about strings.scr and logic.

    Appreciated.

    Code:
    main:
    	local.date = getdate(0)
            while(1)
    	{
    		local.time = gettime(0)
                    local.number=local.time.size-3
                    local.time = waitexec global/strings.scr::left local.number local.time
    		huddraw_align 15 right top
    		huddraw_rect 15 -125 7 0 0
    		huddraw_font 15 "facfont-20"
    		huddraw_alpha 15 1
    		huddraw_color 15 1 1 1
    		huddraw_string 15 (local.date + " - " + local.time + " AEDT")
    		wait 59
    	}
    end
    Last edited by OhGaz; May 18th, 2015 at 12:04 AM.

  5. #25
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    I wrote a date and time API a long time ago. I've spent the last four hours rewriting it. The implementation is based on that of the DateTime struct in .NET

    Download and unrar the script and place it in your main/reborn/ folder. If it does not exist, create it.
    You could also package it in a pk3 as long as the path remains the same.

    In your script, you have to initialize the API before you can use it:
    waitexec reborn/datetime.scr;


    At this point, you can access the API through level.DateTime.
    local.boolean = waitthread level.DateTime.IsLeapYear local.year;

    Determines whether the specified year, or the current year if none specified, is a leap year.
    local.days= waitthread level.DateTime.GetDaysInMonth local.month local.year;

    Determines how many days the specified month has in the specified year, or the current year if none specified.
    local.year = waitthread level.DateTime.GetYear;

    Gets the current year as an integer [1, 9999].
    local.month = waitthread level.DateTime.GetMonth;

    Gets the current month as an integer [1, 12].
    local.day = waitthread level.DateTime.GetDay;

    Gets the current day of the month as an integer [1, 31]
    local.weekday = waitthread level.DateTime.GetDayOfWeek;

    Gets the current day of the week as an integer [0, 6] where Sunday is 0, Monday is 1 etc...
    local.day = waitthread level.DateTime.GetDayOfYear;

    Gets the current day of the year as an integer [1, 366]
    local.hour = waitthread level.DateTime.GetHour;

    Gets the current hour of the current day as an integer [0, 23]
    local.minute = waitthread level.DateTime.GetMinute;

    Gets the current minute of the current hour as an integer [0, 59]
    local.second = waitthread level.DateTime.GetSecond;

    Gets the current second of the current minute as an integer [0, 59]
    local.offset = waitthread level.DateTime.GetTimeZone;

    Gets the local time zone offset [-12, 14]
    local.days = waitthread level.DateTime.GetDayNames;

    Gets a zero-indexed array of names of each week day where index 0 is Sunday, index 1 is Monday etc...
    The value returned by a call to GetDayOfWeek() corresponds to the index in this array.
    local.months = waitthread level.DateTime.GetMonthNames;

    Gets a one-indexed array of names of each month where index 1 is January, index 2 is February etc...
    The value returned by a call to GetMonth() corresponds to the index in this array.
    local.dateTime = waitthread level.DateTime.Create local.second local.minute local.hour local.day local.month local.year local.timeZoneOffset;

    Creates a new DateTime instance of an instant in time. If no time zone offset is specified, the offset of the local time zone will be used.
    local.dateTime = waitthread level.DateTime.Now;

    Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
    local.dateTime = waitthread level.DateTime.UtcNow;

    Gets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC+0).
    local.dateTime2 = waitthread level.DateTime.ToTimeZone local.dateTime local.timeZoneOffset;

    Gets a DateTime object representing the value of the specified DateTime object in the specified time zone.
    local.result = waitthread level.DateTime.Compare local.dateTime local.dateTime2;

    Compares two DateTime objects. This function returns 1 if the first is more recent than the second, -1 if the second is more recent or 0 if they are equal.

    The DateTime instance is simply a Listener object that represents an instant in time, expressed as a date and a time of day.
    The actual date and time are stored as a number of seconds in a day and a number of days since year 0001 AD. This makes
    implementating operations such as addition and subtraction way simpler. Only counting the seconds would have been even
    better but the integer value would overflow. This mean that the object has no public properties for the year, month etc... .
    Luckily, the interface of the object does provide this functionality:
    local.dateTime = local.dateTime waitthread local.dateTime.AddYears local.years;

    Gets a new DateTime instance that adds the specified number of years to the value of this instance.
    local.dateTime = local.dateTime waitthread local.dateTime.AddMonths local.months;

    Gets a new DateTime instance that adds the specified number of months to the value of this instance.
    local.dateTime = local.dateTime waitthread local.dateTime.AddDays local.days;

    Gets a new DateTime instance that adds the specified number of days to the value of this instance.
    local.dateTime = local.dateTime waitthread local.dateTime.AddHours local.hours;

    Gets a new DateTime instance that adds the specified number of hours to the value of this instance.
    local.dateTime = local.dateTime waitthread local.dateTime.AddMinutes local.minutes;

    Gets a new DateTime instance that adds the specified number of minutes to the value of this instance.
    local.dateTime = local.dateTime waitthread local.dateTime.AddSeconds local.seconds;

    Gets a new DateTime instance that adds the specified number of seconds to the value of this instance.
    local.result = local.dateTime waitthread local.dateTime.CompareTo local.dateTime2;

    Compares two DateTime objects. This function returns 1 if the first is more recent than the second, -1 if the second is more recent or 0 if they are equal.
    local.year = local.dateTime waitthread local.dateTime.GetYear;

    Gets the year component of the date represented by this instance as an integer [1, 9999].
    local.month = local.dateTime waitthread local.dateTime.GetMonth;

    Gets the month component of the date represented by this instance as an integer [1, 12].
    local.day = local.dateTime waitthread local.dateTime.GetDay;

    Gets the day of the month represented by this instance as an integer [1, 31]
    local.weekday = local.dateTime waitthread local.dateTime.GetDayOfWeek;

    Gets the day of the week represented by this instance as an integer [0, 6] where Sunday is 0, Monday is 1 etc...
    local.day = local.dateTime waitthread local.dateTime.GetDayOfYear;

    Gets the day of the year represented by this instance as an integer [1, 366]
    local.hour = local.dateTime waitthread local.dateTime.GetHour;

    Gets the hour component of the date represented by this instance as an integer [0, 23]
    local.minute = local.dateTime waitthread local.dateTime.GetMinute;

    Gets the minute component of the date represented by this instance as an integer [0, 59]
    local.second = local.dateTime waitthread local.dateTime.GetSecond;

    Gets the hour component of the date represented by this instance as an integer [0, 59]
    local.offset = local.dateTime waitthread local.dateTime.GetTimeZone;

    Gets the time zone offset of the date represented by this instance as an integer [-12, 14]
    local.localTime = local.dateTime waitthread local.dateTime.ToLocalTime;

    Converts the value of this DateTime object to local time.
    local.utcTime = local.dateTime waitthread local.dateTime.ToUniversalTime;

    Converts the value of this DateTime object to Coordinated Universal Time (UTC+0).
    println(local.dateTime waitthread local.dateTime.ToTimeString);

    Gets the time component and time zone offset of the date represented by this instance as a string.
    println(local.dateTime waitthread local.dateTime.ToDateString);

    Gets the date component of the date represented by this instance as a string.
    println(local.dateTime waitthread local.dateTime.ToString);

    Gets the date represented by this instance as a string.

    Finally, if you're done with a DateTime object, you will have to dispose it like so.
    local.dateTime waitthread local.dateTime.Dispose;


    Beware that exceptions will be thrown if invalid input is given to any function. Currently two exceptions are thrown,
    ArgumentNullException and InvalidArgumentException. Handle them as follows:
    try {
         local.dateTime = waitthread level.DateTime.Create 0 0 0 18 5 2015;
    } catch {
         InvalidArgumentException:
              println("Could not create DateTime object.");
    }


    try {
         local.year = local.dateTime waitthread local.dateTime.GetYear;
    } catch {
         ArgumentNullException:
              println("DateTime object is null.");
    }


    Download:
    datetime.rar
    Last edited by Sor; May 18th, 2015 at 02:08 PM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  6. #26
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,245

    Default

    Just WOW! Amazing job!!!

  7. #27
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,071

    Default

    pffff james , the new coloring is bullshit for mohaa :L
    and ctrl+f5 doesn't work for chrome O.o


    Ryback, what coloring theme/convention would you like to see? I asked people for input and haven't really heard anything. I'd like to make it as "user friendly" as possible, so let me know.
    And Ctrl + F5 does work, because I just tested it on my version of chrome and it updates properly. Try maybe manually deleting your cookies and cache through browser advanced settings.

    @Sor - Incredible job man.

    @own3mall, do we have git setup for pk3's? I think this would be an excellent addition to the pak8. I also think armageddon's mod that he created for speccing players would be a nice addition.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •